package com.woniuxy.shiro.mapper;

import com.woniuxy.shiro.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

@Mapper
@Repository //解决serviceImpl中注入mapper报错问题   idea编译器的问题  对代码没影响
public interface UserMapper {
    @Select("select * from user where account = #{account}")
    public User findUserByAccount(String account);

    //通过账号查询用户的信息及角色信息
    @Select("select * from user where account = #{account}")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "id",property = "roles"
                    ,many = @Many(select = "com.woniuxy.shiro.mapper.RoleMapper.findRolesByUid"))
    })
    public User findUserAndRolesByAccount(String account);
}
